<?php

use UC_PHP\FileSystem as FS;

$file = new FS\File('index.php');
$folder = new FS\Folder('test_dir');

$name1 = 'new folder name';
$name2 = 'another folder name';

try
{
    $folder->get_subfolders()->add_folder($name1);
}
catch(\UC_PHP\FileSystem\FileSystemException $e)
{
    echo '<p>' . $e->getMessage() . '</p>';
}

// or:

if(\UC_PHP\FileSystem\FileSystem::folder_exists($folder->get_path() . '/' . $name2))
{
    echo '<p>' . "$name2: The directory already exists." . '</p>';
}
else
{
    $folder->get_subfolders()->add_folder($name2);
}

foreach($folder->get_subfolders() as $folder)
{
    echo '<p>' . $folder->get_name() . '</p>';
}
